@extends('layouts.admin')
@section('content')
    <style>
        .table tbody tr td{
            text-align:center;
        }
        .dataTables_filter{
            margin-left:20px;
        }
        form input{
            height:22px;
            text-align: center;
            line-height:20px;
            font-size:15px;
        }
    </style>

    <div id="content-header">
        <h1>Tables</h1>
        <div class="btn-group">
            <a class="btn btn-large tip-bottom" title="Manage Files"><i class="icon-file"></i></a>
            <a class="btn btn-large tip-bottom" title="Manage Users"><i class="icon-user"></i></a>
            <a class="btn btn-large tip-bottom" title="Manage Comments"><i class="icon-comment"></i><span class="label label-important">5</span></a>
            <a class="btn btn-large tip-bottom" title="Manage Orders"><i class="icon-shopping-cart"></i></a>
        </div>
    </div>
    <div id="breadcrumb">
        <a href="#" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> Home</a>
        <a href="#" class="current">Tables</a>
    </div>
    <div class="dataTables_filter" id="DataTables_Table_0_filter">
        <form action="{{url('admin/memberdata')}}" method="get" enctype="multipart/form-data">
            {{csrf_field()}}
            <input type="text" name="username"  placeholder="会员用户名">&nbsp;&nbsp;&nbsp;
            <input type="submit"value="搜索">
        </form>
    </div>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="span12">
                <div class="widget-box">
                    <div class="widget-title">
								<span class="icon">
									<i class="icon-th"></i>
								</span>
                        <h5>会员列表</h5>
                    </div>
                    <div class="widget-content nopadding">
                        <table class="table table-bordered table-striped">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>用户ID</th>
                                <th>用户名</th>
                                <th>手机号</th>
                                <th>消息</th>
                                <th>状态</th>
                            </tr>
                            </thead>
                            <tbody id="tbody">
                            {{--在后台遍历数据--}}
                            @foreach($result as $d)
                                <tr>
                                    <td style="text-align:center;line-height:50px">{{$d->id}}</td>
                                    <td style="text-align:center;line-height:50px">{{$d->user_id}}</td>
                                    <td style="text-align:center;line-height:50px">{{$d->username}}</td>
                                    <td style="text-align:center;line-height:50px">{{$d->phone}}</td>
                                    <td style="text-align:center;line-height:50px">{{$d->news}}</td>
                                    <td style="text-align:center;line-height:50px">
                                        @if($d->status==1)
                                            <button class="btn btn-primary" id="btn{{$d->id}}" onclick="changestatus(this,{{$d->id}})">
                                                已发送
                                            </button>
                                        @else
                                            <button class="btn btn-primary" style="background:red;"id="btn{{$d->id}}" onclick="changestatus(this,{{$d->id}})">
                                               撤回
                                            </button>
                                        @endif
                                            | <button type="button" class="btn btn-danger"><a href="{{url('admin/NewsDel',['id'=>$d->id])}}"onclick="if(confirm('确定删除吗?')==false) return false;" style="color:white">删除</a></button>

                                            {{--| <button class="btn btn-primary" style="background:rebeccapurple;" id="newsbtn" value="{{$d->id}}">--}}
                                               {{--发送消息--}}
                                            {{--</button>--}}
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                        <div class="dataTables_paginate">

                            {{$result->links()}}
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row-fluid">
            <div id="footer" class="span12">
                2012 &copy; Unicorn Admin. Brought to you by <a href="https://wrapbootstrap.com/user/diablo9983">diablo9983</a>
            </div>
        </div>
    </div>

    {{--消息填写--}}
    {{--<div class="widget-box" style="width:600px;height:250px;position:fixed;left:500px;top:100px;z-index:9999;display:none;" id="news">--}}
        {{--<div class="widget-title">--}}
        {{--<span class="icon">--}}
            {{--<i class="icon-th"></i>--}}
        {{--</span>--}}
            {{--<h5>消息填写</h5>--}}
        {{--</div>--}}
        {{--<div class="widget-content nopadding" style="margin-top:30px;border-bottom: none">--}}
            {{--<form action="{{url('admin/Send')}}" method="post" style="position: relative;left:50px;">--}}
                {{--{{csrf_field()}}--}}
                {{--<input type="hidden" name="user_id" value="" id="getid">--}}
                {{--消息：<textarea type="text" name="news" maxlength="100" style="width:400px;height:100px;">--}}
                     {{--</textarea><br>--}}
                {{--<button type="submit" class="btn btn-success" style="background: #428BCA;position: relative;top:20px;left:200px;">确定</button>--}}

            {{--</form>--}}
        {{--</div>--}}
    {{--</div>--}}
    <script>
        function changestatus(obj,id){
            $.post("{{url('admin/changeStatus')}}",{'_token':'{{csrf_token()}}','id':id},function(data){
                if(data.status==0){
                    layer.alert(data.msg, {icon: 6});
                    if ($('#btn'+id).html()=='已发送') {
                        $('#btn'+id).html('撤回');
                        $('#btn'+id).css('background','red');
                    }else{
                        $('#btn'+id).html('已发送');
                        $('#btn'+id).css('background','#428BCA');
                    }
                }else{
                    layer.msg(data.msg, {icon: 5});
                }
            });
        }
////        发送消息
//        $('#newsbtn').click(function()
//        {
//            var uid=$(this).attr('value');
//            $('#news').css('display','block');
//            $('#getid').val(uid);
//        })
    </script>
@endsection





